var actclub_user = require('./club_user')
var actmodel={}
actmodel.getactleadgroup=function(){
  var app =getApp()
  var homeurl=app.globalData.configdata["basic"]["homeurl"] 
  if(app.globalData.actleadgroup){
    return new Promise((resolve) => {
      resolve(app.globalData.actleadgroup)   
    })   
  }
  else
  {
    return new Promise((resolve) => {
    actclub_user.centerinfo().then(res => {
      if (res["status"] == 1) {
        var mygroups = res["obj"]["mygroups"]
        if (mygroups) {
          var actleadgroup = actclub_user.initleadgroup(mygroups)
          resolve(actleadgroup)      
         
        }
        else
        {
          resolve(null)          
          
        }
      }
      else
      {
        resolve(null)   
        resolve({status:-1,obj:null})  
        wx.redirectTo({
          url:homeurl,
        })
      }
    }) 
  })
  }
}
 
 
module.exports = actmodel;